import moment from 'moment'

// 处理空值默认值
let filterNullValue = (val) => { 
  switch (val) {
    case 0:
      return 0;
    case null:
      return "--";
    case undefined:
      return "--";
    case "":
      return "--";
    default:
      return val;
  }
}

/*
*  毫秒数  转 指定日期格式
*  1610180784000 转 2021-01-09 16:26:24
*/ 
const msToformatTime = (time, format = 'YYYY-MM-DD HH:mm:ss') => {
  const newTime = moment(time).format(format);  
  return newTime
}

// 格式化字符串
const formatString = (val) => {
  return val.slice(0,-1) 
}

export default{
  filterNullValue,
  msToformatTime,
  formatString,
}